package com.tdam2014.grupo01.adapters;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;

import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tdam2014.grupo01.R;
import com.tdam2014.grupo01.adapters.PhotoListAdapter.updateImageBitmap;
import com.tdam2014.grupo01.objects.*;

public class CommentsListAdapter extends BaseAdapter {
	
	private LayoutInflater inflater;
	private Context context;
	private List<Comments> listaComentarios;
	
	public CommentsListAdapter(Context context)
	{
		this.context = context;
		inflater = LayoutInflater.from(context);
	}
	
	
	public void setList(List<Comments> list) 
	{
		this.listaComentarios = list;
	}

	@Override
	public int getCount() 
	{
		return listaComentarios.size();
	}

	@Override
	public Object getItem(int position) 
	{
		return listaComentarios.get(position);
	}

	@Override
	public long getItemId(int position) 
	{
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		Holder holder;
		
		if(convertView == null)
		{
			holder = new Holder();
			convertView = inflater.inflate(R.layout.item_lista_comentarios, null);
			holder.comentario = (TextView) convertView.findViewById(R.id.nombreDirectorioLista);
			holder.nombreComentario = (TextView) convertView.findViewById(R.id.nombreComentador);
			convertView.setTag(holder);
		}
		else
		{
			holder = (Holder) convertView.getTag();
		}
		
		Comments coment = listaComentarios.get(position);
		
		
		holder.comentario.setText(coment.get_content());
		holder.nombreComentario.setText(coment.getRealname());
		
		return convertView;
	}
	
	static class Holder
	{
		TextView nombreComentario, comentario;
	}
	

}
